home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Plug-In Power Pack for Netscape Communicator
/
Plug-In Power Pack for Netscape Communicator.iso
/
plugins
/
dataviews
/
dvtools
/
demos
/
dwpdemo
/
dwp_model.c
< prev
next >
Wrap
C/C++ Source or Header
|
1997-07-10
|
4KB
|
150 lines
#ifndef lint
static char SccsId[]= "@(#)dwp_model.c V1.8 3/15/95";
#endif
/*------------------------------------------------------------------
| file name -- dwp_model.c
|
| functions Description
| --------- -----------
| InitApplication Calls init_data_table() and init_app_model().
|
| init_data_table Initializes the data table.
|
|-----------------------------------------------------------------*/
#include "std.h"
#include "dvstd.h"
#include "dvtools.h"
#include "VOstd.h"
#include "dwp_vars.h"
#include "dwp_data.h"
#include "VOfundecl.h"
#include "VTfundecl.h"
#include "dwp_fundecl.h"
/***************** Begin Function Declarations *************/
LOCAL void init_data_table V_P_((void));
/***************** End Function Declarations *************/
/*-----------------------------------------------------------------
|
| InitApplication
| Performs the initialization needed for the application.
| Calls init_data_table().
*/
void InitApplication
V_P_ ((void))
{
/* initialize the real-time name:data look up table */
init_data_table (); /* found below */
}
/*-----------------------------------------------------------------
|
| init_data_table
| Initialize the Data Table. The Data Table is a symbol table of
| variable names and their data buffer. This table is used by
| DV-Tools to rebind DV-Draw variables to application data.
*/
LOCAL void init_data_table
V_P_ ((void))
{
INT i;
/* Create the symbol table */
DataTable = VTstcreate ("Data Name and Info", (VTSTCOMPAREFUNPTR)NULL);
/* Make entries for the name buffer pairs defined by DataInfo
| in dwp_data.c
*/
for (i = 0; i < MAX_APP_VARS; i++)
{
VTstsninsert (DataTable, StrClone (DataInfo[i].varname),
(INT *) & DataInfo[i]);
}
}
/*-----------------------------------------------------------------
|
| SelectWindow
| Translate the command into the key for the window.
|
*/
void
SelectWindow (name, number)
char *name;
int *number;
{
if (S_STRCMP (name, "ammonia") == 0)
*number = AMMONIA;
else if (S_STRCMP (name, "hp_drum_detail") == 0)
*number = HP_DRUM;
else if (S_STRCMP (name, "lp_drum_detail") == 0)
*number = LP_DRUM;
else if (S_STRCMP (name, "help") == 0)
*number = HELP;
else if (S_STRCMP (name, "legend") == 0)
*number = LEGEND;
else if (S_STRCMP (name, "ammonia") == 0)
*number = AMMONIA;
else if (S_STRNCMP (name, "Valve", 5) == 0)
{
*number = HAND;
whichvalve = S_ATOI (&name[5]);
}
}
/*-----------------------------------------------------------------
|
| DoCommand
| Execute the command that is associated with the picked
| object.
|
*/
void
DoCommand (name)
char *name;
{
if (S_STRCMP (name, "apply") == 0)
change_valve ();
else if (S_STRCMP (name, "reset") == 0)
reset ();
else if (S_STRCMP (name, "toggle_overlay") == 0)
toggle_overlay = (toggle_overlay) ? (FLOAT)0.0 : (FLOAT)1.0;
}
/*==================================================================
|
| StrClone
| Allocates space for and makes a copy of a specified string,
| returning a pointer to the string. If there is no input
| string, the routine returns a NULL.
*/
CHAR *StrClone( str )
CHAR *str;
{
FAST INT len;
CHAR *newstr;
FAST CHAR *to;
FAST CHAR *from;
if( str == NULL )
return( NULL );
len = S_STRLEN( str ) + 1;
newstr = (CHAR *)S_ALLOC( len );
if( newstr )
for( to = newstr, from = str; len > 0; len-- )
*to++ = *from++;
return( newstr );
}